package com.sjzd.weixin.menu;

import com.sjzd.weixin.bean.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class MenuManager {
    @Value("${wx.domainName}")
    private String domainName;

    /**
     * 组建菜单内容
     */
    public Menu buildMenu() {
        /*-----一栏------*/
        ComplexButton main10 = new ComplexButton();
        main10.setName("讲座");
        ViewButton sub11 = new ViewButton();
        sub11.setName("讲座发单");
        sub11.setUrl(domainName + "/weixin/publish");
        ClickButton sub12 = new ClickButton();
        sub12.setName("讲座抢单");
        sub12.setKey("12");
        main10.setSub_button(new SubButton[]{sub11, sub12});

        /*------二栏--------*/
        ComplexButton main20 = new ComplexButton();
        main20.setName("公告板");
        ViewButton sub21 = new ViewButton();
        sub21.setName("召开排行榜");
        sub21.setUrl(domainName + "/meetingPublish/publishRank");
        main20.setSub_button(new SubButton[]{sub21});

        /*------三栏--------*/
        ComplexButton main30 = new ComplexButton();
        main30.setName("系统消息");
        ViewButton sub31 = new ViewButton();
        sub31.setName("个人中心");
        sub31.setUrl(domainName + "/weixin/selfCenter");
        ViewButton sub32 = new ViewButton();
        sub32.setName("版本信息");
        sub32.setUrl("https://www.baidu.com/");
        ClickButton sub33 = new ClickButton();
        sub33.setName("联系我们");
        sub33.setKey("33");
        main30.setSub_button(new SubButton[]{sub31, sub32, sub33});
        /*-------组成菜单----------*/
        Menu menu = new Menu();
        menu.setButton(new Button[]{main10,main20, main30});
        return menu;
    }
}
